#pragma once
#ifndef __VF_SHOWSECTION3D__
#define __VF_SHOWSECTION3D__
#include <vf_sink.h>
#include <list>
#include <vector>

// {E9DC2E6D-78CB-4C2F-B407-EF5CAE5F3F59}
DEFINE_GUID(CLSID_CmdShowSection3D, 0xe9dc2e6d, 0x78cb, 0x4c2f, 0xb4, 0x7, 0xef,
            0x5c, 0xae, 0x5f, 0x3f, 0x59);

namespace VFAdapter {

class CmdShowSection3D
    : public ATL::CComObjectRoot,
      public ATL::CComCoClass<CmdShowSection3D, &CLSID_CmdShowSection3D>,
      public fw::ISECommandEvents,
      public CEventSink<fw::ISECommandEvents>,
      public fw::ISEMouseEvents,
      public CEventSink<fw::ISEMouseEvents>,
      public fw::ISELocateFilterEvents,
      public CEventSink<fw::ISELocateFilterEvents>,
      public fw::ISEIGLDisplayEvents,
      public CEventSink<fw::ISEIGLDisplayEvents> {
  BEGIN_COM_MAP(CmdShowSection3D)
  COM_INTERFACE_ENTRY(fw::ISECommandEvents)
  COM_INTERFACE_ENTRY(fw::ISEMouseEvents)
  COM_INTERFACE_ENTRY(fw::ISELocateFilterEvents)
  COM_INTERFACE_ENTRY(fw::ISEIGLDisplayEvents)
  END_COM_MAP()
  DECLARE_NOT_AGGREGATABLE(CmdShowSection3D)

public:
  CmdShowSection3D();
  typedef ATL::CComPtr<ATL::CComObject<CmdShowSection3D>> CmdShowSection3DPtr;
  static CmdShowSection3DPtr GetInstance();
  ~CmdShowSection3D();
  void StartCommand();

private:
  void DisConnnectEvent();

private:
  STDMETHOD(raw_Activate)(void);

  STDMETHOD(raw_Deactivate)(void);

  STDMETHOD(raw_Terminate)(void);

  STDMETHOD(raw_Idle)(long lCount, VARIANT_BOOL *pbMore);

  STDMETHOD(raw_KeyDown)(short *KeyCode, short Shift);

  STDMETHOD(raw_KeyPress)(short *KeyAscii);

  STDMETHOD(raw_KeyUp)(short *KeyCode, short Shift);

  STDMETHOD(raw_MouseDown)
  (short sButton, short sShift, double dX, double dY, double dZ,
   LPDISPATCH pWindowDispatch, long lKeyPointType, LPDISPATCH pGraphicDispatch);

  STDMETHOD(raw_MouseUp)
  (short sButton, short sShift, double dX, double dY, double dZ,
   LPDISPATCH pWindowDispatch, long lKeyPointType, LPDISPATCH pGraphicDispatch);
  STDMETHOD(raw_MouseMove)
  (short sButton, short sShift, double dX, double dY, double dZ,
   LPDISPATCH pWindowDispatch, long lKeyPointType, LPDISPATCH pGraphicDispatch);

  STDMETHOD(raw_MouseClick)
  (short sButton, short sShift, double dX, double dY, double dZ,
   LPDISPATCH pWindowDispatch, long lKeyPointType, LPDISPATCH pGraphicDispatch);
  STDMETHOD(raw_MouseDblClick)
  (short sButton, short sShift, double dX, double dY, double dZ,
   LPDISPATCH pWindowDispatch, long lKeyPointType, LPDISPATCH pGraphicDispatch);
  STDMETHOD(raw_MouseDrag)
  (short sButton, short sShift, double dX, double dY, double dZ,
   LPDISPATCH pWindowDispatch, short DragState, long lKeyPointType,
   LPDISPATCH pGraphicDispatch);

  STDMETHOD(raw_Filter)(LPDISPATCH pGraphicDispatch, VARIANT_BOOL *vbValid);

  STDMETHOD(raw_BeginDisplay)(void);
  STDMETHOD(raw_EndDisplay)(void);
  STDMETHOD(raw_BeginIGLMainDisplay)(LPUNKNOWN pGL);
  STDMETHOD(raw_EndIGLMainDisplay)(LPUNKNOWN pGL);

private:
  fw::ISECommandPtr m_pSeCmd = nullptr;
  fw::ISEMouseExPtr m_pSeMouse = nullptr;

  //
  std::list<std::vector<Eigen::Vector<double, 3>>> m_drawingList;

public:
  void ShowGeometry(std::vector<Eigen::Vector<double, 3>> &geometry);
};

} // namespace VFAdapter

#endif